package kr.aow.database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ResourceBundle;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

public class ConnectionFactory {
	public static Connection getConnection(){
//		ResourceBundle rb = ResourceBundle.getBundle("db");
		Connection conn = null;
//		String url = rb.getString("url");
//		String user = rb.getString("username");
//		String password = rb.getString("password");
		try {
//			DBCP용 커넥션 생성코드
//			conn = DriverManager.getConnection("jdbc:apache:commons:dbcp:pool");
//			JNDI 용 커넥션 생성코드
			Context ctx = new InitialContext();
			DataSource dataSource = (DataSource) ctx.lookup("java:/comp/env/jdbc/mainDB");
			conn = dataSource.getConnection();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return conn;			
	}
}
